package views;

import java.awt.BorderLayout;
import java.sql.ResultSet;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import presenters.LocationPrefReportPresenter;

public class LocationPrefReportPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6253448062439282856L;
	private LocationPrefReportPresenter myPresenter;
	JTable table;
	
	public LocationPrefReportPanel() {
		String[] columnNames = {"Month",
                "Location",
                "No. Reservations",
                "Total No. Hours",
           };
		
		Object[][] data = {
				{"1","1","1","1"}
			};
		
		table = new JTable(data, columnNames);
		add(new JScrollPane(table), BorderLayout.CENTER);
		
		
		myPresenter = new LocationPrefReportPresenter(this);
	}
	
	public void addData(ResultSet rs) {
		/*
		ArrayList<Object> newData = new ArrayList<Object>();
		rs.first();
		String month = rs.getString("MONTH");
		String location = rs.getString("LOCATION");
		String numResv = rs.getString("NO_RESV");
		String totalHours = rs.getString("TOTAL_HOURS");
		newData.add(month);
		newData.add(location);
		newData.add(numResv);
		newData.add(totalHours);
		
		while(rs.next()) {
		String month = rs.getString("MONTH");
		String location = rs.getString("LOCATION");
		String numResv = rs.getString("NO_RESV");
		String totalHours = rs.getString("TOTAL_HOURS");
		newData.add(month);
		newData.add(location);
		newData.add(numResv);
		newData.add(totalHours);
		}
		
		addInData = new Object[newData.size()/4][3];
		int k = 0;
		for (int i = 0; i < newData.size()/4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				addInData[i][j] = newData.get(k);
				k++;
			}
		}
		table = new JTable(addInData, columnNames);
		revalidate();
		*/
		
	}
	
	public LocationPrefReportPresenter getMyPresenter() {
		return myPresenter;
	}
}
